﻿using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class frmMainDesktop : System.Web.UI.Page 
{
    public string strParentMenuHtml, strChildMenuHtml,strIconData;
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            Business.Menu.XtMenuOperation xmoTemp = new Business.Menu.XtMenuOperation();
            DataTable dt = xmoTemp.GenerateParentMenu();

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //获取父菜单
                    string menuid = dt.Rows[i]["menu_parent_id"].ToString();
                    string menuname = dt.Rows[i]["menu_parent_desc"].ToString();
                    if (i == 0)
                    {
                       strParentMenuHtml += "<a class=\"currTab\" title=\"" + menuname + "\" href=\"javascript:void(0)\" rel=\"" + menuid + "\"></a>";
                    }
                    else
                    {
                        strParentMenuHtml += "<a title=\"" + menuname + "\" href=\"javascript:void(0)\" rel=\"" + menuid + "\"></a>";
                    }

                    //获取子菜单
                    DataTable dt1 = xmoTemp.GetChildMenu(menuid);
                    strChildMenuHtml+="<ul style=\"width: 1203px; height: 771px; margin-right: 73px\" class=\"deskIcon\">";

                    if (dt1.Rows.Count > 0)
                    {
                        for (int k = 0; k < dt1.Rows.Count; k++)
                        {
                            string newMenuId = dt1.Rows[k]["menu_child_id"].ToString();
                            string newMenuTitle = dt1.Rows[k]["menu_child_desc"].ToString();
                            string newMenuUrl = dt1.Rows[k]["linkhref"].ToString();
                            string newMenuPic = dt1.Rows[k]["overpic"].ToString();

                            if (!string.IsNullOrEmpty(strIconData))
                            {
                                strIconData += ",";
                            }
                            strIconData += "'" + newMenuId + "':{'title':'" + newMenuTitle + "','url':'" + newMenuUrl + "','winWidth':950,'winHeight':500}";

                            strChildMenuHtml += string.Format("<li style=\"position: absolute; margin: 0px; top: 20px; left: 30px\" id=\"{0}\" class=\"desktop_icon\"><span class=\"icon\"><img src=\"" + newMenuPic + "\"></span><div class=\"text\">{1}<s></s></div></li>", newMenuId, newMenuTitle);
                        }
                    }
                    strChildMenuHtml+="<li style=\"position: absolute; margin: 0px; top: 140px; left: 150px\" class=\"desktop_icon\"><span class=\"icon\"><img src=\"images/add_icon.png\"></span><div class=\"text\">添加<s></s></div></li>";
                    strChildMenuHtml+="</ul>";
                }
            }
        }
    }


}
